function EventEmiter(){
	this.callbacks = {}
}

EventEmiter.prototype.on = function(eventName, handler){
	if ( ! this.callbacks[eventName]) {
		this.callbacks[eventName] = []
	}
	this.callbacks[eventName].push(handler)
	// body... argument
}

EventEmiter.prototype.emit = function(eventName){
	if ( ! this.callbacks[eventName]) {
		return
	}
	var args = [].splice.call(arguments, 1)
	this.callbacks[eventName].forEach( handler => {
		handler.apply(null, args)
	})
}

function Cat(){
	EventEmiter.call(this)
}

Cat.prototype = new EventEmiter()

var c1 = new Cat()
c1.on('meow', function(){
	console.log('meow meow meow ~~~')
})

function Dog(){
	EventEmiter.call(this)
}
Dog.prototype = new EventEmiter()

var d1 = new Dog()
d1.on('meow', function(){
	console.log('wang wang wang~~~')
})

c1.emit('meow')